{# SPDX-License-Identifier: Apache-2.0 -#}
{% extends "base.html" %}
{% block title %}
  {% if form and form.errors %}
    {% trans %}Error processing form{% endtrans %} –
  {% endif %}
  {% trans %}Password reset{% endtrans %}
{% endblock %}
{% block content %}
  <div class="horizontal-section">
    <div class="site-container">
      <h1 class="page-title">{% trans %}Password reset{% endtrans %}</h1>
      {% if form %}
        <form method="post" action="{{ request.current_route_path() }}">
          <p>{% trans %}To reset your password, enter your username or email.{% endtrans %}</p>
          <input name="csrf_token"
                 type="hidden"
                 value="{{ request.session.get_csrf_token() }}">
          {% if form.form_errors %}
            <ul class="form-errors" role="alert">
              {% for error in form.form_errors %}<li>{{ error }}</li>{% endfor %}
            </ul>
          {% endif %}
          <div class="form-group">
            <label for="username_or_email" class="form-group__label">
              {% trans %}Username or email{% endtrans %}
              {% if form.username_or_email.flags.required %}
                <span class="form-group__required">{% trans %}(required){% endtrans %}</span>
              {% endif %}
            </label>
            {% include "warehouse:templates/includes/input-user-name.html" %}
          </div>
          <input type="submit"
                 value="{% trans %}Request password reset{% endtrans %}"
                 class="button button--primary">
        </form>
      {% else %}
        <div class="callout-block callout-block--success">
          <h2 class="callout-block__heading">{% trans %}Reset email sent{% endtrans %}</h2>
          <p>
            {% trans %}If you submitted a valid username or verified email address, an email has been sent to your registered email address.{% endtrans %}
          </p>
          <p>
            {% trans n_hours=n_hours %}The email contains a link to reset your password. This link will expire in {{ n_hours }} hours.{% endtrans %}
          </p>
        </div>
      {% endif %}
    </div>
  </div>
{% endblock %}
